cmake_minimum_required(VERSION 2.8.12)
set(libname Bes3)
project(${libname})

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(ROOTEVENTDATA_DIR ${CMAKE_SOURCE_DIR}/RootEventData)

include(FindProtobuf)
include(FindROOT)
include(MacRpathPatch)
configure_file(
	${CMAKE_SOURCE_DIR}/cmake/RootEventDataVer.h.cmake
	${CMAKE_SOURCE_DIR}/RootEventData/RootEventDataVer.h
)

add_subdirectory(RootEventData)

include_directories(
	${CMAKE_SOURCE_DIR}
	${CMAKE_BINARY_DIR}
	${PROTOBUF_INCLUDE_DIRS}
	${ROOTEVENTDATA_DIR}/RootEventData
	${ROOT_INCLUDE_DIR}
)

set( SRC_FILES ObjectHook.cpp)
set( HEADER_FILES ObjectHook.hpp )

file(GLOB PROTO_FILES proto/*.proto)
foreach(EVTPROTO ${PROTO_FILES})
	protobuf_generate_cpp(EVTPROTO_CC EVTPROTO_H ${EVTPROTO})
	list(APPEND SRC_FILES ${EVTPROTO_CC})
	list(APPEND HEADER_FILES ${EVTPROTO_H})
endforeach()

add_library(${libname} SHARED ${SRC_FILES} ${HEADER_FILES})
target_link_libraries(${libname}
	RootEventData
	${PROTOBUF_LIBRARIES}
)
